package com.oasystem.domain;

import java.io.Serializable;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

public class Operator implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3931474020159992679L;
	private int id;
	private String name;
	private String userName;
	private String password;
	private Date createDate;

	private List<Permission> permissions = new ArrayList<Permission>();

	public Operator() {
	}
	
	public Operator(String loginName, String password) {
		this.userName=loginName;
		this.password=password;
	}

	public List<Permission> getPermissions() {
		return permissions;
	}

	public void setPermissions(List<Permission> permissions) {
		this.permissions = permissions;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public void copy(Operator operator) {
		this.id = operator.getId();
		this.createDate = operator.getCreateDate();
		this.name = operator.getName();
		this.userName = operator.getUserName();
		this.password = operator.getPassword();
		this.permissions = operator.getPermissions();
	}
	
	
	public boolean isAllowAddMember() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==1)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowAddMember(boolean allowAddMember) {
	}
	public boolean isAllowSearchMember() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==2)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowSearchMember(boolean allowSearchMember) {
	}
	public boolean isAllowSummaryMember() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==3)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowSummaryMember(boolean allowSummaryMember) {
	}
	public boolean isAllowAddProfit() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==4)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowAddProfit(boolean allowAddProfit) {
	}
	public boolean isAllowSearchProfit() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==5)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowSearchProfit(boolean allowSearchProfit) {
	}
	public boolean isAllowSummaryProfit() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==6)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowSummaryProfit(boolean allowSummaryProfit) {
	}
	public boolean isAllowManageOperator() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==7)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowManageOperator(boolean allowManageOperator) {
	}
	public boolean isAllowManageGoods() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==8)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowManageGoods(boolean allowManageGoods) {
	}
	public boolean isAllowManageDepartment() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==9)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowManageDepartment(boolean allowManageDepartment) {
	}
	public boolean isAllowManageDataSafe() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==10)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowManageDataSafe(boolean allowManageDataSafe) {
	}
	public boolean isAllowMemberSystem() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==1||permission.getPermissionID()==2||permission.getPermissionID()==3)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowMemberSystem(boolean allowMemberSystem) {
	}
	public boolean isAllowProfitSystem() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==4||permission.getPermissionID()==5||permission.getPermissionID()==6)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowProfitSystem(boolean allowProfitSystem) {
	}
	public boolean isAllowConfigSystem() {
		for(Permission permission : permissions){
			if(permission.getPermissionID()==7||permission.getPermissionID()==8||permission.getPermissionID()==9||permission.getPermissionID()==10)
			{
				return true;
			}
		}
		return false;
	}
	public void setAllowConfigSystem(boolean allowConfigSystem) {
	}
//	private boolean allowAddMember;
//	private boolean allowSearchMember;
//	private boolean allowSummaryMember;
	
//	private boolean allowAddProfit;
//	private boolean allowSearchProfit;
//	private boolean allowSummaryProfit;
	
//	private boolean allowManageOperator;
//	private boolean allowManageGoods;
//	private boolean allowManageDepartment;
//	private boolean allowManageDataSafe;
//	
//	private boolean allowMemberSyste;
//	private boolean allowProfitSystem;
//	private boolean allowConfigSystem;
}
